home *** CD-ROM | disk | FTP | other *** search
- unit WSpell;
- {-spell dialog for EDSSpell component}
- interface
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, Menus,
- ExtCtrls, EDSUtil, SpellInt;
-
- type
- Languages = (lgEnglish, lgSpanish);
- const
- MaxBuffer = 65535;
- DictExt : String[4] = '.DIC';
- Dictionaries : Array[Languages] of String[8] =
- ('English', 'Spanish');
- EnglishStrings : Array[Languages] of String[15] =
- ('English', 'Spanish');
- SpanishStrings : Array[Languages] of String[15] =
- ('InglΘs', 'Espa±ol');
- type
- TBigBuffer = Array[1..MaxBuffer] of Char;
- PBigBuffer = ^TBigBuffer;
-
- type
- Accents = (acSpanish);
- AccentSet = Set of Accents;
- TSpellWin = class(TForm)
- lblFound: TLabel;
- lblNotFound: TLabel;
- lblReplace: TLabel;
- edtWord: TEnterEdit;
- lblSuggestions: TLabel;
- lstSuggest: TNewListBox;
- btnReplace: TBitBtn;
- btnSkip: TBitBtn;
- btnSkipAll: TBitBtn;
- btnSuggest: TBitBtn;
- btnAdd: TBitBtn;
- btnClose: TBitBtn;
- pnlIcons: TPanel;
- btnA: TSpeedButton;
- btnE: TSpeedButton;
- btnI: TSpeedButton;
- btnO: TSpeedButton;
- btnU: TSpeedButton;
- btnN: TSpeedButton;
- btnN2: TSpeedButton;
- procedure edtWordExit(Sender: TObject);
- procedure btnSuggestClick(Sender: TObject);
- procedure lstSuggestChange(Sender: TObject);
- procedure lstSuggestDblClick(Sender: TObject);
- procedure btnAddClick(Sender: TObject);
- procedure lblSuggestionsClick(Sender: TObject);
- procedure FormKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure AccentClick(Sender: TObject);
- procedure lstSuggestMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- private
- { Private declarations }
- public
- { Public declarations }
- NumToSuggest: byte;
- end;
-
- implementation
-
- {$R *.DFM}
-
- procedure TSpellWin.edtWordExit(Sender: TObject);
- var
- ChkWord: String;
- begin
- lblNotFound.Caption := edtWord.Text;
- if ActiveControl is TBitBtn then
- exit;
- ChkWord := edtWord.Text;
- if dllInDictionary (ChkWord) then
- begin
- lblFound.Caption := 'Word found:';
- ActiveControl := btnReplace;
- end {:} else
- begin
- lblFound.Caption := 'Not found:';
- ActiveControl := btnSuggest;
- end; { else }
- end;
-
- procedure TSpellWin.btnSuggestClick(Sender: TObject);
- var
- TempList: TStringList;
- begin
- TempList := dllSuggestWords (edtWord.Text, NumToSuggest);
- lstSuggest.Items.Assign (TempList);
- TempList.Free;
- end;
-
- procedure TSpellWin.lstSuggestChange(Sender: TObject);
- begin
- if lstSuggest.ItemIndex<>-1 then
- edtWord.Text := lstSuggest.Items[lstSuggest.ItemIndex];
- end;
-
- procedure TSpellWin.lstSuggestDblClick(Sender: TObject);
- begin
- if lstSuggest.ItemIndex<>-1 then
- edtWord.Text := lstSuggest.Items[lstSuggest.ItemIndex];
- ModalResult := btnReplace.ModalResult;
- end;
-
- procedure TSpellWin.btnAddClick(Sender: TObject);
- begin
- if not dllInDictionary (lblNotFound.Caption) then
- begin
- if MessageDlg ('Add ' + lblNotFound.Caption + ' to Dictionary?',
- mtConfirmation, [mbYes, mbNo], 0) = mrYes then
- dllAddWord (lblNotFound.Caption);
- end {:} else
- MessageDlg (lblNotFound.Caption + ' already in Dictionary.',
- mtInformation, [mbOk], 0);
- ActiveControl := edtWord;
- end;
-
- procedure TSpellWin.lblSuggestionsClick(Sender: TObject);
- begin
- Top := 15;
- end;
-
- procedure TSpellWin.FormKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- var
- ClearKey: Boolean;
- begin
- ClearKey := TRUE;
- case Key of
- Ord ('e'): if ssAlt in Shift then ActiveControl := lstSuggest;
- Ord ('w'): if ssAlt in Shift then ActiveControl := edtWord;
- else ClearKey := FALSE;
- end; { case }
- if ClearKey then Key := 0;
- end;
-
- procedure TSpellWin.AccentClick(Sender: TObject);
- begin
- if Sender is TSpeedButton then
- edtWord.SelText := TSpeedButton (Sender).Caption[1];
- end; { TSpellWin.AccentClick }
-
- procedure TSpellWin.lstSuggestMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- NewIndex: integer;
- begin
- NewIndex := Y div lstSuggest.ItemHeight;
- if NewIndex>lstSuggest.Items.Count-1 then
- NewIndex := lstSuggest.Items.Count-1;
- lstSuggest.ItemIndex := NewIndex;
- end;
-
- end. { WSpell }
-